<?php
/**
*	模块信息
*/
namespace Rainrock\Framework\kernel\core;


use Rainrock\Framework\kernel\base\File;
class Module{
	
	/**
	*	获取模块
	*/
	public static function get($num,$group='')
	{
		if($group=='auto')$group = self::getGroup($num);
		return Aock::getModule($num, $group);
	}
	
	
	/**
	*	获取模块所有的列表
	*/
	public static function getList()
	{
		$files		= File::getFolder(''.ROOT_PATM.'/'.PACKPATH.'/Module', function($f,$p){
			$slu = ''.$p.'/'.$f.'';
			$alls = File::getFolder($slu);
			return array(
				$f => $alls
			);
		});
		$garr		= array();
		foreach($files as $groups)foreach($groups as $gs=>$als)$garr[$gs] = $als;
		return $garr;
	}
	
	/**
	*	获取模块对应的租编号
	*/
	public static function getGroup($num)
	{
		$group 	= '';
		$groups	= self::getList();
		foreach($groups as $gs=>$als)if(in_array($num, $als))$group = $gs;
		return $group;
	}
	
	/**
	*	获取监听
	*/
	public static function getListener($num, $group)
	{
		return Aock::getModuleListener($num, $group);
	}
}